Good morning,
I can create files and write strings/unicodes.
Is it possible to write a list, a dictionary or an object or anything into a
file? Or do I have to transform them to strings?
Péter
___
Tutor maillist - Tutor@python.org
To unsubscribe or ch
2011/6/2 Válas Péter :
> Good morning,
>
> I can create files and write strings/unicodes.
> Is it possible to write a list, a dictionary or an object or anything into a
> file? Or do I have to transform them to strings?
Yes you can.
I guess the question is how you want the information to be structu
2011. június 2. 9:29 Simon Yan írta, :
> Yes you can.
> I guess the question is how you want the information to be structured.
> IMHO, everything in Python can be "string-lized".
>
> What is the syntax then? I have Windows XP. The code is:
f=open("xxx.dat","w")
f.write("fff")
d={'one':1, 2:'two'}
2011/6/2 Válas Péter :
>
>
> 2011. június 2. 9:29 Simon Yan írta, :
>>
>> Yes you can.
>> I guess the question is how you want the information to be structured.
>> IMHO, everything in Python can be "string-lized".
>>
> What is the syntax then? I have Windows XP. The code is:
> f=open("xxx.dat","w"
>Is it possible to write a list, a dictionary or an object or anything into
a file? Or do I have to transform them to strings?
Have a look at the pickle module:
http://docs.python.org/library/pickle.html
___
Tutor maillist - Tutor@python.org
To unsubsc
"Válas Péter" wrote
I can create files and write strings/unicodes.
Is it possible to write a list, a dictionary or an object or
anything into a
file? Or do I have to transform them to strings?
You can write anything to a file, but the file will need to
be opened in binary mode(see the docs).
"Válas Péter" wrote
Modified code:
f=open("xxx.dat","wb") The others remain as above, just I wrote wb.
Yes, you need to use binary mode.
I read something about a pack function, is that the key?
See the file handling topic in my tutorial for a simple
example of using the struct module(whic
2011. június 2. 10:52 Simon Yan írta, :
> Try this:
> f.write(str(d))
>
> That's what I first asked, this is not a structured file then, this is a
structure transformed to a string.
Thanks for the idea of pickle, I will look at it.
___
Tutor maillist -
On 01/-10/-28163 02:59 PM, Válas Péter wrote:
2011. június 2. 9:29 Simon Yan írta,:
Yes you can.
I guess the question is how you want the information to be structured.
IMHO, everything in Python can be "string-lized".
What is the syntax then? I have Windows XP. The code is:
f=open("xxx.dat",
I fixed it. I find if I sleep on things I have a better chance at fixing
them. Maybe I will get some real work done today instead of going all OCD on
this side project?
Here's the dif: http://pastebin.com/KYBab3H9
I'll address your points in a second, but here's how I found the problem
(Python is
>If not, he can google the bits he doesn't understand, or ask. We won't bite!
Unless he asks for it ;)
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
This communication is for informational purpo
Hello everyone
I'm not sure if introductions are customary on this list but I thought
I would anyway as I'm going to be using it quite a bit from now.
I am just starting out with python and I will no doubt get stuck and
need some assistance from you all soon. I'll try my best to keep the
stupidit
On Thu, Jun 2, 2011 at 10:12 AM, Jamie Griffin wrote:
> Hello everyone
>
> I'm not sure if introductions are customary on this list but I thought
> I would anyway as I'm going to be using it quite a bit from now.
>
> I am just starting out with python and I will no doubt get stuck and
> need some
2011/6/2 Válas Péter :
> I can create files and write strings/unicodes.
> Is it possible to write a list, a dictionary or an object or anything into a
> file? Or do I have to transform them to strings?
As suggested by Walter, you should use the Pickle module to serialize
your Python objects so the
"Alexandre Conrad" wrote
you want to share that data between non-Python application, I could
also suggest the use of the JSON module. JSON is a standard format
(see json.org) supported by many programming languages.
But isn't it a string based format?
I thought JSON converted everything int
On 2 June 2011 17:13, Alan Gauld wrote:
> But isn't it a string based format?
> I thought JSON converted everything into XML strings?
>
>
It's text based yes, although not XML. As for efficiency, I'd be of the
view that it's probably efficient enough for the vast majority of use cases,
especiall
Alan Gauld wrote:
"Alexandre Conrad" wrote
you want to share that data between non-Python application, I could
also suggest the use of the JSON module. JSON is a standard format
(see json.org) supported by many programming languages.
But isn't it a string based format?
I thought JSON conve
>But I've only used JSON once from within TurboGears so
>I am no expert!
If you use Firefox you have used JSON ;) that is how it stores bookmarks. I am
sure it is more widely used than that. Usage seems to be on the rise but that
could be that I see it more now that I know what it is.
Ramit
Thank you for your careful explanation, Steven.
I guess there's nothing more for me to know.
While I think it is a mistake to put directories in your package directory
structure that aren't part of the package, that seems to be all it's
about.
Well, I guess I don't feel quite so stupid.
Thank y
True that!
This is the nicest, most patient, most knowledgeable, technical list I've
ever experienced.
That's why I keep coming back when I am hopelessly confused.
Thank you.
Marilyn Davis
On Thu, June 2, 2011 7:04 am, Prasad, Ramit wrote:
>> If not, he can google the bits he doesn't underst
> When you hit the page and you get an HTTP redirect code back (say,
> 302), you will need to make another call to the URL specified in the
> "Location" parameter in the response headers. Then you retrieve that
> new page and you can check you got an acceptable HTTP response code
> (such as 200) an
On Thu, Jun 2, 2011 at 4:06 PM, Robert Sjoblom wrote:
> Python already has the urllib/urllib2 package that automatically
> follow redirects, so I don't see why you'd need a 3rd-party module to
> deal with it? When it encounters a 301 status code from the server,
Ah, but I believe the issue is tha
On 2 June 2011 22:50, Brett Ritter wrote:
> On Thu, Jun 2, 2011 at 4:06 PM, Robert Sjoblom
> wrote:
>> Python already has the urllib/urllib2 package that automatically
>> follow redirects, so I don't see why you'd need a 3rd-party module to
>> deal with it? When it encounters a 301 status code f
"Prasad, Ramit" wrote
>But I've only used JSON once from within TurboGears so
If you use Firefox you have used JSON ;)
Yeah, OK, I've used JSON on loads of apps in that sense.
I meant I've only programmed with JSON once...
But I suspect you knew that! :-)
--
Alan Gauld
Author of the L
"Steven D'Aprano" wrote
That makes it hugely wasteful of space which is usually the reason
for using a binary format in the first place.
Meh, who cares whether your 100K of data takes 300K on disk? :)
It depends on your volumes and your platform. About 10 years
ago I bought 10G of storage f
25 matches
Mail list logo