LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2010, 01:52 AM   #1
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Python 2 to Python 3


Hopefully a quickie (but I can't seem to find anything so far).

I have a function definition in a Python 2.x script which take a
tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x

Code:
def blah(self, (string1, string2)):
Any help greatly appreciated

Cheers
Grail
 
Old 03-04-2010, 02:40 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by grail View Post
Hopefully a quickie (but I can't seem to find anything so far).

I have a function definition in a Python 2.x script which take a
tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x

Code:
def blah(self, (string1, string2)):
Any help greatly appreciated

Cheers
Grail
ask you question at stackoverflow or comp.lang.python
 
Old 03-04-2010, 08:19 AM   #3
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
Code:
def blah(self, string_tuple):
    string1, string2 = string_tuple
 
Old 03-04-2010, 06:46 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Hi Dan

Please let me know if your solution still works in the following scenario?

Code:
def blah(self, (string1, string2)):
    return blah2('help', (string1, string2)) 

def blah2(self, name, stringx=None):
    ...
 
Old 03-04-2010, 10:24 PM   #5
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
Yes, it will. Passing a tuple to a function is unaffected. You just can't declare function arguments like that anymore. Here's why.
 
  


Reply

Tags
python311



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 04:50 AM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
LXer: Charming Python: Python elegance and warts, Part 2 LXer Syndicated Linux News 0 08-31-2007 08:40 AM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration